package com.dingli.controller;

import com.dingli.framework.entity.Resume;
import com.dingli.framework.entity.Train;
import com.dingli.framework.entity.Undertake;
import com.dingli.framework.util.Response;
import com.dingli.service.ITrainService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@CrossOrigin("*")
@RestController
@RequestMapping("/train")
@Api(tags = "全媒体培训管理")
public class TrainController {

    @Autowired
    private ITrainService iTrainService;

    @GetMapping("/TRAIN_selectList")
    @ApiOperation("培训信息列表查询")
    public Response<PageInfo<Train>> TRAIN_selectList(@ApiParam("查询条件")
                                                    @RequestParam(required = false) String search,
                                                @ApiParam("页码") @RequestParam(required = false) Integer pageNum,
                                                @ApiParam("页面大小")
                                                    @RequestParam(required = false) Integer pageSize) {
        return iTrainService.TRAIN_selectList(search, pageNum, pageSize);
    }

    @GetMapping("/TRAIN_selectAll")
    @ApiOperation("培训信息详情查看")
    public Response<List<Train>>TRAIN_selectAll(@ApiParam("项目ID") @RequestParam Long tnId) {
        return iTrainService.TRAIN_selectAll(tnId);
    }

    @PostMapping("/TRAIN_insert")
    @ApiOperation("培训信息新增")
    public Object TRAIN_insert(@ApiParam("培训信息") @RequestBody Train train) {
        return iTrainService.TRAIN_insert(train);
    }

    @PostMapping("/TRAIN_updateById")
    @ApiOperation("培训信息修改")
    public Response<Object> TRAIN_updateById(@ApiParam("修改培训信息") @RequestBody Train train) {

        return iTrainService.TRAIN_updateById(train);
    }

    @GetMapping("/TRAIN_deleteById")
    @ApiOperation("培训信息删除")
    public Response<Object> TRAIN_deleteById(@ApiParam("培训信息ID") @RequestParam Long tnId) {
        return iTrainService.TRAIN_deleteById(tnId);
    }

    @PostMapping("/ReupdateState")
    @ApiOperation("培训信息审核")
    public Response<Object> TRAIN_updateState(@ApiParam("审核培训信息通过") @RequestBody String tnId) {
        return iTrainService.TRAIN_updateState(tnId);
    }

    @PostMapping("/TRAIN_update")
    @ApiOperation("培训信息审核")
    public Response<Object> TRAIN_update(@ApiParam("审核培训信息不通过") @RequestBody String tnId) {

        return iTrainService.TRAIN_update(tnId);
    }

    @RequestMapping ("/TRAIN_selectState")
    @CrossOrigin
    @ApiOperation("审核查询")
    public HashMap<Object, Object> TRAIN_selectState(@ApiParam("审核中查询") @RequestParam String tnState){
        Response<List<Train>> list = iTrainService.TRAIN_selectState(tnState);
        HashMap<Object, Object> ob = new HashMap<>();
        ob.put("Train",list);
        ob.put("size",list.getData().size());
        return ob;
    }

    @RequestMapping ("/TRAIN_selectState1")
    @CrossOrigin
    @ApiOperation("审核查询")
    public  HashMap<Object, Object> TRAIN_selectState1(@ApiParam("审核通过查询") @RequestParam String tnState){
        Response<List<Train>> list = iTrainService.TRAIN_selectState1(tnState);
        HashMap<Object, Object> yy = new HashMap<>();
        yy.put("Train",list);
        yy.put("size",list.getData().size());
        return yy;
    }

    @RequestMapping ("/TRAIN_All")
    @CrossOrigin
    @ApiOperation("培训信息统计")
    public HashMap<Object, Object> TRAIN_All(@ApiParam("培训信息统计") @RequestParam String tnId){
        Response<List<Train>> list = iTrainService.TRAIN_All(tnId);
        HashMap<Object, Object> yy = new HashMap<>();
//        wh.put("Train",list);
        yy.put("size",list.getData().size());
        return yy;
    }
}
